package com.bjsxt.reflex;

import java.lang.reflect.Field;

public class GetField2 {
    public static void main(String[] args) throws NoSuchFieldException, InstantiationException, IllegalAccessException {
        Class clazz = Users.class;
        Field field = clazz.getField("age");
        Object obj = clazz.newInstance();
        field.set(obj,18);
        Object o = field.get(obj);
        System.out.println(o);
    }
}
